<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- qcursor.cpp -->
  <title>QCursor Class | Qt GUI 5.14.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QCursor</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.14.2 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#a-note-for-x11-users">A Note for X11 Users</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QCursor Class</h1>
<!-- $$$QCursor-brief -->
<p>The QCursor class provides a mouse cursor with an arbitrary shape. <a href="#details">More...</a></p>
<!-- @@@QCursor -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QCursor&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr></table></div><ul>
<li><a href="qcursor-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#QCursor-5">QCursor</a></b>(QCursor &amp;&amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#QCursor-4">QCursor</a></b>(const QCursor &amp;<i>c</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#QCursor-3">QCursor</a></b>(const QPixmap &amp;<i>pixmap</i>, int <i>hotX</i> = -1, int <i>hotY</i> = -1)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#QCursor-2">QCursor</a></b>(const QBitmap &amp;<i>bitmap</i>, const QBitmap &amp;<i>mask</i>, int <i>hotX</i> = -1, int <i>hotY</i> = -1)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#QCursor-1">QCursor</a></b>(Qt::CursorShape <i>shape</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#QCursor">QCursor</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QCursor &amp;</td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#operator-eq-1">operator=</a></b>(QCursor &amp;&amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QCursor &amp;</td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#operator-eq">operator=</a></b>(const QCursor &amp;<i>c</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#dtor.QCursor">~QCursor</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QBitmap *</td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#bitmap">bitmap</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#hotSpot">hotSpot</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QBitmap *</td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#mask">mask</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPixmap </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#pixmap">pixmap</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#setShape">setShape</a></b>(Qt::CursorShape <i>shape</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Qt::CursorShape </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#shape">shape</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#swap">swap</a></b>(QCursor &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#operator-QVariant">operator QVariant</a></b>() const</td></tr>
</table></div>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#pos">pos</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#pos-1">pos</a></b>(const QScreen *<i>screen</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#setPos">setPos</a></b>(int <i>x</i>, int <i>y</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#setPos-1">setPos</a></b>(QScreen *<i>screen</i>, int <i>x</i>, int <i>y</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#setPos-2">setPos</a></b>(const QPoint &amp;<i>p</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#setPos-3">setPos</a></b>(QScreen *<i>screen</i>, const QPoint &amp;<i>p</i>)</td></tr>
</table></div>
<a name="related-non-members"></a>
<h2 id="related-non-members">Related Non-Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#operator-not-eq-5">operator!=</a></b>(const QCursor &amp;<i>lhs</i>, const QCursor &amp;<i>rhs</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#operator-lt-lt">operator&lt;&lt;</a></b>(QDataStream &amp;<i>stream</i>, const QCursor &amp;<i>cursor</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#operator-eq-eq-3">operator==</a></b>(const QCursor &amp;<i>lhs</i>, const QCursor &amp;<i>rhs</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qcursor.html#operator-gt-gt">operator&gt;&gt;</a></b>(QDataStream &amp;<i>stream</i>, QCursor &amp;<i>cursor</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QCursor-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>This class is mainly used to create mouse cursors that are associated with particular widgets and to get and set the position of the mouse cursor.</p>
<p>Qt has a number of standard cursor shapes, but you can also make custom cursor shapes based on a <a href="qbitmap.html">QBitmap</a>, a mask and a hotspot.</p>
<p>To associate a cursor with a widget, use <a href="../qtwidgets/qwidget.html#cursor-prop">QWidget::setCursor</a>(). To associate a cursor with all widgets (normally for a short period of time), use <a href="qguiapplication.html#setOverrideCursor">QGuiApplication::setOverrideCursor</a>().</p>
<p>To set a cursor shape use <a href="qcursor.html#setShape">QCursor::setShape</a>() or use the QCursor constructor which takes the shape as argument, or you can use one of the predefined cursors defined in the <a href="../qtcore/qt.html#CursorShape-enum">Qt::CursorShape</a> enum.</p>
<p>If you want to create a cursor with your own bitmap, either use the QCursor constructor which takes a bitmap and a mask or the constructor which takes a pixmap as arguments.</p>
<p>To set or get the position of the mouse cursor use the static methods <a href="qcursor.html#pos">QCursor::pos</a>() and <a href="qcursor.html#setPos">QCursor::setPos</a>().</p>
<p><b>Note:</b> It is possible to create a QCursor before <a href="qguiapplication.html">QGuiApplication</a>, but it is not useful except as a place-holder for a real QCursor created after <a href="qguiapplication.html">QGuiApplication</a>. Attempting to use a QCursor that was created before <a href="qguiapplication.html">QGuiApplication</a> will result in a crash.</p>
<a name="a-note-for-x11-users"></a>
<h3 id="a-note-for-x11-users">A Note for X11 Users</h3>
<p>On X11, Qt supports the <a href="http://www.xfree86.org/4.3.0/Xcursor.3.html">Xcursor</a> library, which allows for full color icon themes. The table below shows the cursor name used for each <a href="../qtcore/qt.html#CursorShape-enum">Qt::CursorShape</a> value. If a cursor cannot be found using the name shown below, a standard X11 cursor will be used instead. Note: X11 does not provide appropriate cursors for all possible <a href="../qtcore/qt.html#CursorShape-enum">Qt::CursorShape</a> values. It is possible that some cursors will be taken from the Xcursor theme, while others will use an internal bitmap cursor.</p>
<div class="table"><table class="generic">
 <thead><tr class="qt-style"><th >Shape</th><th ><a href="../qtcore/qt.html#CursorShape-enum">Qt::CursorShape</a> Value</th><th >Cursor Name</th><th >Shape</th><th ><a href="../qtcore/qt.html#CursorShape-enum">Qt::CursorShape</a> Value</th><th >Cursor Name</th></tr></thead>
<tr valign="top" class="odd"><td ><img src="images/cursor-arrow.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::ArrowCursor</a></td><td ><code>left_ptr</code></td><td ><img src="images/cursor-sizev.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::SizeVerCursor</a></td><td ><code>size_ver</code></td></tr>
<tr valign="top" class="even"><td ><img src="images/cursor-uparrow.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::UpArrowCursor</a></td><td ><code>up_arrow</code></td><td ><img src="images/cursor-sizeh.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::SizeHorCursor</a></td><td ><code>size_hor</code></td></tr>
<tr valign="top" class="odd"><td ><img src="images/cursor-cross.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::CrossCursor</a></td><td ><code>cross</code></td><td ><img src="images/cursor-sizeb.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::SizeBDiagCursor</a></td><td ><code>size_bdiag</code></td></tr>
<tr valign="top" class="even"><td ><img src="images/cursor-ibeam.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::IBeamCursor</a></td><td ><code>ibeam</code></td><td ><img src="images/cursor-sizef.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::SizeFDiagCursor</a></td><td ><code>size_fdiag</code></td></tr>
<tr valign="top" class="odd"><td ><img src="images/cursor-wait.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::WaitCursor</a></td><td ><code>wait</code></td><td ><img src="images/cursor-sizeall.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::SizeAllCursor</a></td><td ><code>size_all</code></td></tr>
<tr valign="top" class="even"><td ><img src="images/cursor-busy.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::BusyCursor</a></td><td ><code>left_ptr_watch</code></td><td ><img src="images/cursor-vsplit.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::SplitVCursor</a></td><td ><code>split_v</code></td></tr>
<tr valign="top" class="odd"><td ><img src="images/cursor-forbidden.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::ForbiddenCursor</a></td><td ><code>forbidden</code></td><td ><img src="images/cursor-hsplit.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::SplitHCursor</a></td><td ><code>split_h</code></td></tr>
<tr valign="top" class="even"><td ><img src="images/cursor-hand.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::PointingHandCursor</a></td><td ><code>pointing_hand</code></td><td ><img src="images/cursor-openhand.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::OpenHandCursor</a></td><td ><code>openhand</code></td></tr>
<tr valign="top" class="odd"><td ><img src="images/cursor-whatsthis.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::WhatsThisCursor</a></td><td ><code>whats_this</code></td><td ><img src="images/cursor-closedhand.png" alt="" /></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::ClosedHandCursor</a></td><td ><code>closedhand</code></td></tr>
<tr valign="top" class="even"><td ></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::DragMoveCursor</a></td><td ><code>dnd-move</code> or <code>move</code></td><td ></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::DragCopyCursor</a></td><td ><code>dnd-copy</code> or <code>copy</code></td></tr>
<tr valign="top" class="odd"><td ></td><td ><a href="../qtcore/qt.html#CursorShape-enum">Qt::DragLinkCursor</a></td><td ><code>dnd-link</code> or <code>link</code></td></tr>
</table></div>
</div>
<p><b>See also </b><a href="../qtwidgets/qwidget.html">QWidget</a> and <a href="../qtwidgets/guibooks.html#fowler">GUI Design Handbook: Cursors</a>.</p>
<!-- @@@QCursor -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QCursor$$$QCursorQCursor&& -->
<h3 class="fn" id="QCursor-5"><a name="QCursor-5"></a>QCursor::<span class="name">QCursor</span>(<span class="type"><a href="qcursor.html#QCursor">QCursor</a></span> &amp;&amp;<i>other</i>)</h3>
<p>Move-constructs a cursor from <i>other</i>. After being moved from, the only valid operations on <i>other</i> are destruction and (move and copy) assignment. The effects of calling any other member function on a moved-from instance are undefined.</p>
<p>This function was introduced in Qt 5.5.</p>
<!-- @@@QCursor -->
<!-- $$$QCursor$$$QCursorconstQCursor& -->
<h3 class="fn" id="QCursor-4"><a name="QCursor-4"></a>QCursor::<span class="name">QCursor</span>(const <span class="type"><a href="qcursor.html#QCursor">QCursor</a></span> &amp;<i>c</i>)</h3>
<p>Constructs a copy of the cursor <i>c</i>.</p>
<!-- @@@QCursor -->
<!-- $$$QCursor$$$QCursorconstQPixmap&intint -->
<h3 class="fn" id="QCursor-3"><a name="QCursor-3"></a>QCursor::<span class="name">QCursor</span>(const <span class="type"><a href="qpixmap.html">QPixmap</a></span> &amp;<i>pixmap</i>, <span class="type">int</span> <i>hotX</i> = -1, <span class="type">int</span> <i>hotY</i> = -1)</h3>
<p>Constructs a custom pixmap cursor.</p>
<p><i>pixmap</i> is the image. It is usual to give it a mask (set using <a href="qpixmap.html#setMask">QPixmap::setMask</a>()). <i>hotX</i> and <i>hotY</i> define the cursor's hot spot.</p>
<p>If <i>hotX</i> is negative, it is set to the <code>pixmap().width()/2</code>. If <i>hotY</i> is negative, it is set to the <code>pixmap().height()/2</code>.</p>
<p>Valid cursor sizes depend on the display hardware (or the underlying window system). We recommend using 32 x 32 cursors, because this size is supported on all platforms. Some platforms also support 16 x 16, 48 x 48, and 64 x 64 cursors.</p>
<p><b>See also </b><a href="qpixmap.html#QPixmap">QPixmap::QPixmap</a>() and <a href="qpixmap.html#setMask">QPixmap::setMask</a>().</p>
<!-- @@@QCursor -->
<!-- $$$QCursor$$$QCursorconstQBitmap&constQBitmap&intint -->
<h3 class="fn" id="QCursor-2"><a name="QCursor-2"></a>QCursor::<span class="name">QCursor</span>(const <span class="type"><a href="qbitmap.html">QBitmap</a></span> &amp;<i>bitmap</i>, const <span class="type"><a href="qbitmap.html">QBitmap</a></span> &amp;<i>mask</i>, <span class="type">int</span> <i>hotX</i> = -1, <span class="type">int</span> <i>hotY</i> = -1)</h3>
<p>Constructs a custom bitmap cursor.</p>
<p><i>bitmap</i> and <i>mask</i> make up the bitmap. <i>hotX</i> and <i>hotY</i> define the cursor's hot spot.</p>
<p>If <i>hotX</i> is negative, it is set to the <code>bitmap().width()/2</code>. If <i>hotY</i> is negative, it is set to the <code>bitmap().height()/2</code>.</p>
<p>The cursor <i>bitmap</i> (B) and <i>mask</i> (M) bits are combined like this:</p>
<ul>
<li>B=1 and M=1 gives black.</li>
<li>B=0 and M=1 gives white.</li>
<li>B=0 and M=0 gives transparent.</li>
<li>B=1 and M=0 gives an XOR'd result under Windows, undefined results on all other platforms.</li>
</ul>
<p>Use the global Qt color <a href="../qtcore/qt.html#GlobalColor-enum">Qt::color0</a> to draw 0-pixels and <a href="../qtcore/qt.html#GlobalColor-enum">Qt::color1</a> to draw 1-pixels in the bitmaps.</p>
<p>Valid cursor sizes depend on the display hardware (or the underlying window system). We recommend using 32 x 32 cursors, because this size is supported on all platforms. Some platforms also support 16 x 16, 48 x 48, and 64 x 64 cursors.</p>
<p><b>See also </b><a href="qbitmap.html#QBitmap">QBitmap::QBitmap</a>() and <a href="qpixmap.html#setMask">QBitmap::setMask</a>().</p>
<!-- @@@QCursor -->
<!-- $$$QCursor$$$QCursorQt::CursorShape -->
<h3 class="fn" id="QCursor-1"><a name="QCursor-1"></a>QCursor::<span class="name">QCursor</span>(<span class="type"><a href="../qtcore/qt.html#CursorShape-enum">Qt::CursorShape</a></span> <i>shape</i>)</h3>
<p>Constructs a cursor with the specified <i>shape</i>.</p>
<p>See <a href="../qtcore/qt.html#CursorShape-enum">Qt::CursorShape</a> for a list of shapes.</p>
<p><b>See also </b><a href="qcursor.html#setShape">setShape</a>().</p>
<!-- @@@QCursor -->
<!-- $$$QCursor[overload1]$$$QCursor -->
<h3 class="fn" id="QCursor"><a name="QCursor"></a>QCursor::<span class="name">QCursor</span>()</h3>
<p>Constructs a cursor with the default arrow shape.</p>
<!-- @@@QCursor -->
<!-- $$$operator=$$$operator=QCursor&& -->
<h3 class="fn" id="operator-eq-1"><a name="operator-eq-1"></a><span class="type"><a href="qcursor.html#QCursor">QCursor</a></span> &amp;QCursor::<span class="name">operator=</span>(<span class="type"><a href="qcursor.html#QCursor">QCursor</a></span> &amp;&amp;<i>other</i>)</h3>
<p>Move-assigns <i>other</i> to this <a href="qcursor.html">QCursor</a> instance.</p>
<p>This function was introduced in Qt 5.2.</p>
<!-- @@@operator= -->
<!-- $$$operator=[overload1]$$$operator=constQCursor& -->
<h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qcursor.html#QCursor">QCursor</a></span> &amp;QCursor::<span class="name">operator=</span>(const <span class="type"><a href="qcursor.html#QCursor">QCursor</a></span> &amp;<i>c</i>)</h3>
<p>Assigns <i>c</i> to this cursor and returns a reference to this cursor.</p>
<!-- @@@operator= -->
<!-- $$$~QCursor[overload1]$$$~QCursor -->
<h3 class="fn" id="dtor.QCursor"><a name="dtor.QCursor"></a>QCursor::<span class="name">~QCursor</span>()</h3>
<p>Destroys the cursor.</p>
<!-- @@@~QCursor -->
<!-- $$$bitmap[overload1]$$$bitmap -->
<h3 class="fn" id="bitmap"><a name="bitmap"></a>const <span class="type"><a href="qbitmap.html">QBitmap</a></span> *QCursor::<span class="name">bitmap</span>() const</h3>
<p>Returns the cursor bitmap, or <code>nullptr</code> if it is one of the standard cursors.</p>
<!-- @@@bitmap -->
<!-- $$$hotSpot[overload1]$$$hotSpot -->
<h3 class="fn" id="hotSpot"><a name="hotSpot"></a><span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> QCursor::<span class="name">hotSpot</span>() const</h3>
<p>Returns the cursor hot spot, or (0, 0) if it is one of the standard cursors.</p>
<!-- @@@hotSpot -->
<!-- $$$mask[overload1]$$$mask -->
<h3 class="fn" id="mask"><a name="mask"></a>const <span class="type"><a href="qbitmap.html">QBitmap</a></span> *QCursor::<span class="name">mask</span>() const</h3>
<p>Returns the cursor bitmap mask, or <code>nullptr</code> if it is one of the standard cursors.</p>
<!-- @@@mask -->
<!-- $$$pixmap[overload1]$$$pixmap -->
<h3 class="fn" id="pixmap"><a name="pixmap"></a><span class="type"><a href="qpixmap.html">QPixmap</a></span> QCursor::<span class="name">pixmap</span>() const</h3>
<p>Returns the cursor pixmap. This is only valid if the cursor is a pixmap cursor.</p>
<!-- @@@pixmap -->
<!-- $$$pos[overload1]$$$pos -->
<h3 class="fn" id="pos"><a name="pos"></a><code>[static] </code><span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> QCursor::<span class="name">pos</span>()</h3>
<p>Returns the position of the cursor (hot spot) of the primary screen in global screen coordinates.</p>
<p>You can call <a href="../qtwidgets/qwidget.html#mapFromGlobal">QWidget::mapFromGlobal</a>() to translate it to widget coordinates.</p>
<p><b>Note: </b>The position is queried from the windowing system. If mouse events are generated via other means (e.g&#x2e;, via QWindowSystemInterface in a unit test), those fake mouse moves will not be reflected in the returned value.</p><p><b>Note: </b>On platforms where there is no windowing system or cursors are not available, the returned position is based on the mouse move events generated via QWindowSystemInterface.</p><p><b>See also </b><a href="qcursor.html#setPos">setPos</a>(), <a href="../qtwidgets/qwidget.html#mapFromGlobal">QWidget::mapFromGlobal</a>(), <a href="../qtwidgets/qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>(), and <a href="qguiapplication.html#primaryScreen-prop">QGuiApplication::primaryScreen</a>().</p>
<!-- @@@pos -->
<!-- $$$pos$$$posconstQScreen* -->
<h3 class="fn" id="pos-1"><a name="pos-1"></a><code>[static] </code><span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> QCursor::<span class="name">pos</span>(const <span class="type"><a href="qscreen.html">QScreen</a></span> *<i>screen</i>)</h3>
<p>Returns the position of the cursor (hot spot) of the <i>screen</i> in global screen coordinates.</p>
<p>You can call <a href="../qtwidgets/qwidget.html#mapFromGlobal">QWidget::mapFromGlobal</a>() to translate it to widget coordinates.</p>
<p><b>See also </b><a href="qcursor.html#setPos">setPos</a>(), <a href="../qtwidgets/qwidget.html#mapFromGlobal">QWidget::mapFromGlobal</a>(), and <a href="../qtwidgets/qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>().</p>
<!-- @@@pos -->
<!-- $$$setPos[overload1]$$$setPosintint -->
<h3 class="fn" id="setPos"><a name="setPos"></a><code>[static] </code><span class="type">void</span> QCursor::<span class="name">setPos</span>(<span class="type">int</span> <i>x</i>, <span class="type">int</span> <i>y</i>)</h3>
<p>Moves the cursor (hot spot) of the primary screen to the global screen position (<i>x</i>, <i>y</i>).</p>
<p>You can call <a href="../qtwidgets/qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>() to translate widget coordinates to global screen coordinates.</p>
<p><b>See also </b><a href="qcursor.html#pos">pos</a>(), <a href="../qtwidgets/qwidget.html#mapFromGlobal">QWidget::mapFromGlobal</a>(), <a href="../qtwidgets/qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>(), and <a href="qguiapplication.html#primaryScreen-prop">QGuiApplication::primaryScreen</a>().</p>
<!-- @@@setPos -->
<!-- $$$setPos$$$setPosQScreen*intint -->
<h3 class="fn" id="setPos-1"><a name="setPos-1"></a><code>[static] </code><span class="type">void</span> QCursor::<span class="name">setPos</span>(<span class="type"><a href="qscreen.html">QScreen</a></span> *<i>screen</i>, <span class="type">int</span> <i>x</i>, <span class="type">int</span> <i>y</i>)</h3>
<p>Moves the cursor (hot spot) of the <i>screen</i> to the global screen position (<i>x</i>, <i>y</i>).</p>
<p>You can call <a href="../qtwidgets/qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>() to translate widget coordinates to global screen coordinates.</p>
<p><b>Note: </b>Calling this function results in changing the cursor position through the windowing system. The windowing system will typically respond by sending mouse events to the application's window. This means that the usage of this function should be avoided in unit tests and everywhere where fake mouse events are being injected via QWindowSystemInterface because the windowing system's mouse state (with regards to buttons for example) may not match the state in the application-generated events.</p><p><b>Note: </b>On platforms where there is no windowing system or cursors are not available, this function may do nothing.</p><p><b>See also </b><a href="qcursor.html#pos">pos</a>(), <a href="../qtwidgets/qwidget.html#mapFromGlobal">QWidget::mapFromGlobal</a>(), and <a href="../qtwidgets/qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>().</p>
<!-- @@@setPos -->
<!-- $$$setPos$$$setPosconstQPoint& -->
<h3 class="fn" id="setPos-2"><a name="setPos-2"></a><code>[static] </code><span class="type">void</span> QCursor::<span class="name">setPos</span>(const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>p</i>)</h3>
<p>This is an overloaded function.</p>
<p>Moves the cursor (hot spot) to the global screen position at point <i>p</i>.</p>
<!-- @@@setPos -->
<!-- $$$setPos$$$setPosQScreen*constQPoint& -->
<h3 class="fn" id="setPos-3"><a name="setPos-3"></a><code>[static] </code><span class="type">void</span> QCursor::<span class="name">setPos</span>(<span class="type"><a href="qscreen.html">QScreen</a></span> *<i>screen</i>, const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>p</i>)</h3>
<p>This is an overloaded function.</p>
<p>Moves the cursor (hot spot) to the global screen position of the <i>screen</i> at point <i>p</i>.</p>
<!-- @@@setPos -->
<!-- $$$setShape[overload1]$$$setShapeQt::CursorShape -->
<h3 class="fn" id="setShape"><a name="setShape"></a><span class="type">void</span> QCursor::<span class="name">setShape</span>(<span class="type"><a href="../qtcore/qt.html#CursorShape-enum">Qt::CursorShape</a></span> <i>shape</i>)</h3>
<p>Sets the cursor to the shape identified by <i>shape</i>.</p>
<p>See <a href="../qtcore/qt.html#CursorShape-enum">Qt::CursorShape</a> for the list of cursor shapes.</p>
<p><b>See also </b><a href="qcursor.html#shape">shape</a>().</p>
<!-- @@@setShape -->
<!-- $$$shape[overload1]$$$shape -->
<h3 class="fn" id="shape"><a name="shape"></a><span class="type"><a href="../qtcore/qt.html#CursorShape-enum">Qt::CursorShape</a></span> QCursor::<span class="name">shape</span>() const</h3>
<p>Returns the cursor shape identifier. The return value is one of the <a href="../qtcore/qt.html#CursorShape-enum">Qt::CursorShape</a> enum values (cast to an int).</p>
<p><b>See also </b><a href="qcursor.html#setShape">setShape</a>().</p>
<!-- @@@shape -->
<!-- $$$swap[overload1]$$$swapQCursor& -->
<h3 class="fn" id="swap"><a name="swap"></a><span class="type">void</span> QCursor::<span class="name">swap</span>(<span class="type"><a href="qcursor.html#QCursor">QCursor</a></span> &amp;<i>other</i>)</h3>
<p>Swaps this cursor with the <i>other</i> cursor.</p>
<p>This function was introduced in Qt 5.7.</p>
<!-- @@@swap -->
<!-- $$$operator QVariant[overload1]$$$operator QVariant -->
<h3 class="fn" id="operator-QVariant"><a name="operator-QVariant"></a><span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span> QCursor::<span class="name">operator QVariant</span>() const</h3>
<p>Returns the cursor as a <a href="../qtcore/qvariant.html">QVariant</a>.</p>
<!-- @@@operator QVariant -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$operator!=$$$operator!=constQCursor&constQCursor& -->
<h3 class="fn" id="operator-not-eq-5"><a name="operator-not-eq-5"></a><span class="type">bool</span> <span class="name">operator!=</span>(const <span class="type"><a href="qcursor.html#QCursor">QCursor</a></span> &amp;<i>lhs</i>, const <span class="type"><a href="qcursor.html#QCursor">QCursor</a></span> &amp;<i>rhs</i>)</h3>
<p>Inequality operator. Returns the equivalent of !(<i>lhs</i> == <i>rhs</i>).</p>
<p>This function was introduced in Qt 5.10.</p>
<p><b>See also </b><a href="qcursor.html#operator-eq-eq-3">operator==</a>(const QCursor &amp;lhs, const QCursor &amp;rhs).</p>
<!-- @@@operator!= -->
<!-- $$$operator<<[overload1]$$$operator<<QDataStream&constQCursor& -->
<h3 class="fn" id="operator-lt-lt"><a name="operator-lt-lt"></a><span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&lt;&lt;</span>(<span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<i>stream</i>, const <span class="type"><a href="qcursor.html#QCursor">QCursor</a></span> &amp;<i>cursor</i>)</h3>
<p>Writes the <i>cursor</i> to the <i>stream</i>.</p>
<p><b>See also </b><a href="../qtcore/datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator<< -->
<!-- $$$operator==$$$operator==constQCursor&constQCursor& -->
<h3 class="fn" id="operator-eq-eq-3"><a name="operator-eq-eq-3"></a><span class="type">bool</span> <span class="name">operator==</span>(const <span class="type"><a href="qcursor.html#QCursor">QCursor</a></span> &amp;<i>lhs</i>, const <span class="type"><a href="qcursor.html#QCursor">QCursor</a></span> &amp;<i>rhs</i>)</h3>
<p>Equality operator. Returns <code>true</code> if <i>lhs</i> and <i>rhs</i> have the same <a href="qcursor.html#shape">shape()</a> and, in the case of <a href="../qtcore/qt.html#CursorShape-enum">bitmap cursors</a>, the same <a href="qcursor.html#hotSpot">hotSpot()</a> and either the same <a href="qcursor.html#pixmap">pixmap()</a> or the same <a href="qcursor.html#bitmap">bitmap()</a> and <a href="qcursor.html#mask">mask()</a>.</p>
<p><b>Note: </b>When comparing bitmap cursors, this function only compares the bitmaps' <a href="qpixmap.html#cacheKey">cache keys</a>, not each pixel.</p><p>This function was introduced in Qt 5.10.</p>
<p><b>See also </b><a href="qcursor.html#operator-not-eq-5">operator!=</a>(const QCursor &amp;lhs, const QCursor &amp;rhs).</p>
<!-- @@@operator== -->
<!-- $$$operator>>[overload1]$$$operator>>QDataStream&QCursor& -->
<h3 class="fn" id="operator-gt-gt"><a name="operator-gt-gt"></a><span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&gt;&gt;</span>(<span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<i>stream</i>, <span class="type"><a href="qcursor.html#QCursor">QCursor</a></span> &amp;<i>cursor</i>)</h3>
<p>Reads the <i>cursor</i> from the <i>stream</i>.</p>
<p><b>See also </b><a href="../qtcore/datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator>> -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
